﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using eschoolBO;

namespace ESCHOOL.students
{
    public partial class masterpage : System.Web.UI.MasterPage
    {
        student stud = new student(); bannerslide bs = new bannerslide();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt = bs.GetRecords(-99, "", "", "Top Banner", "true", false, " and ");
                Image1.ImageUrl = "~/admin/banner/" + dt.Rows[0]["b_image"].ToString();
            }
        }

        protected void btnsubscribe_Click(object sender, EventArgs e)
        {
            MailMessage MyMessage = new MailMessage();
            MailAddress SendFrom = new MailAddress("eschool123g@gmail.com");

            Attachment atc = new Attachment(Server.MapPath("~/admin/newsletter/") + "\\a.txt");
            MyMessage.Attachments.Add(atc);

            MyMessage.To.Add(tbmailid.Text);
            MyMessage.From = SendFrom;
            MyMessage.Subject = "Newsletter";
            MyMessage.Body = "Hello sir";
            System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("eschool123g@gmail.com", "eschool@123");

            SmtpClient emailClient1 = new SmtpClient("smtp.gmail.com");
            emailClient1.EnableSsl = true;
            emailClient1.Port = 587;
            emailClient1.Credentials = basicAuthenticationInfo;
            emailClient1.Send(MyMessage);
        }
    }
}
